{include file="public/header"/}
<script type="text/javascript" src="{__PUBLIC_PATH}/common/js/admin_clipboard.min.js?t={php}echo time();{/php}"></script>
</head>
<body> 
<div class="layui-form">
  <div class="layui-fluid" id="LAY-component-layer-list">
    <div class="layui-col-md12 pd83">
      <div class="layui-card hideshadow">
        <div class="layui-tab layui-tab-brief">
        {include file="web/top"}
        <div class="layui-tab-content">

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">网站状态</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <input type="checkbox" lay-filter="web_status" lay-skin="switch" lay-text="开启|关闭" {if condition="!isset($config.web_status) || $config.web_status eq 1"}checked{/if}>
                <input type="hidden" name="web_status" value="{$config.web_status|default='0'}"/>
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">网站简称</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                  <input type="text" id="web_name" name="web_name" value="{$config.web_name|default=''}" placeholder="即在后台显示的名称" autocomplete="off" class="layui-input">
              </div>
              <div class="layui-input-inline lh38 auto">
                <a class="layui-btn layui-btn-xs web_name" href="javascript:void(0);" data-attr="web_name" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_name{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a>
               </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">网站LOGO</label>
              <div class="layui-input-inline auto">
                <ul class="layout">
                  <li>
                  <input name="web_logo" id="web_logo" placeholder="图片地址" value="{$config.web_logo|default=''}" class="layui-input inp inp_logo">
                  <input type="hidden" name="old_web_logo" value="{$config.web_logo|default=''}">
                  <img id="img_web_logo" src="{$config.web_logo|get_default_pic=###}?v={php}echo time();{/php}" class="none">
                  </li>
                  <li style="margin-top:3px;margin-left:5px;">
                    <div class="layui-btn-group">
                      <input type="button" value="上传图片" class="layui-btn layui-btn-sm pcfcms-upload" lay-data="{number:1,pcf_inputId:'web_logo',pcf_savepath:'allimg'}">
                      <input type="button" value="选择图片" class="layui-btn layui-btn-sm" onClick="GetPictureFolder(1,'web_logo');">
                      <input type="button" value="预览" class="layui-btn layui-btn-sm" onclick="BigImages($('#img_web_logo').attr('src'));">
                      <input type="button" value="清除" class="layui-btn layui-btn-sm layui-btn-warm" data-inputid="web_logo" onclick="DelImages(this);">
                    </div>
                  </li>
                </ul>
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">地址图标</label>
              <div class="layui-input-inline auto">
              <ul class="layout">
                <li style="width:32px;">
                <img id="img_web_ico" src="{$config.web_ico}?v={php}echo time();{/php}" width="32" height="32">
                <input type="hidden" name="web_ico" id="web_ico" placeholder="图片地址" value="{$config.web_ico|default=''}">
                </li>
                <li style="margin-top:1px;margin-left:5px;width:32px;">
                  <div class="layui-btn-group">
                    <input type="button" value="上传图片" class="layui-btn layui-btn-sm pcfcms-upload" lay-data="{number:1,exts:'ico',pcf_inputId:'web_ico',pcf_savepath:'allimg'}">
                  </div>
                </li>
              </ul>
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">网站域名</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <input type="text" name="web_basehost" value="{$config.web_basehost|default=''}" placeholder="{$Request.scheme}://" class="layui-input">
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_basehost" href="javascript:void(0);" data-attr="web_basehost" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_basehost{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>
          
            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">首页标题</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <input type="text" id="web_title" name="web_title" lay-verify="title" placeholder="一般不超过80个字符" value="{$config.web_title|default=''}" class="layui-input">
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_title" href="javascript:void(0);"  data-attr="web_title" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_title{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">首页关键词</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <input type="text" name="web_keywords" lay-verify="title" value="{$config.web_keywords|default=''}" placeholder="一般不超过100个字符" class="layui-input">
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_keywords" href="javascript:void(0);" data-attr="web_keywords" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_keywords{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label pcfcms_layui-form-label">首页描述</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <textarea id="web_description" name="web_description" class="layui-textarea" placeholder="建议不超过200个字符">{$config.web_description|default=''}</textarea>
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_description" href="javascript:void(0);" data-attr="web_description" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_description{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label pcfcms_layui-form-label">版权信息</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <textarea name="web_copyright" class="layui-textarea">{$config.web_copyright|default=''}</textarea>
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_copyright" href="javascript:void(0);" data-attr="web_copyright" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_copyright{php} echo '\' /';{/php}}" data-type="customvar_copy">
              <i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label">备案号</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <input type="text" name="web_recordnum" lay-verify="title" value="{$config.web_recordnum|default=''}" class="layui-input">
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_recordnum" href="javascript:void(0);" data-attr="web_recordnum" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_recordnum{php} echo '\' /';{/php}}" data-type="customvar_copy">
              <i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>
            
            <div class="pcfline"></div>
            <div class="layui-form-item">
              <label class="layui-form-label pcfcms_layui-form-label"><strong>第三方代码</strong></label>
              <div class="layui-input-inline"></div>
            </div>

            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label pcfcms_layui-form-label">电脑PC端</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <textarea name="web_thirdcode_pc" id="web_thirdcode_pc" class="layui-textarea">{$config.web_thirdcode_pc|default=''}</textarea>
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_thirdcode_pc" href="javascript:void(0);"  data-attr="web_thirdcode_pc" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_thirdcode_pc{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>
            
            <div class="layui-form-item layui-form-text">
              <label class="layui-form-label pcfcms_layui-form-label">手机移动端</label>
              <div class="layui-input-inline pcfcms_layui-input-inline">
                <textarea name="web_thirdcode_wap" id="web_thirdcode_wap" class="layui-textarea">{$config.web_thirdcode_wap|default=''}</textarea>
              </div>
              <div class="layui-input-inline auto lh38"><a class="layui-btn layui-btn-xs web_thirdcode_wap" href="javascript:void(0);" data-attr="web_thirdcode_wap" data-clipboard-text="{{php} echo 'gzpcf:global name=\'';{/php}web_thirdcode_wap{php} echo '\' /';{/php}}" data-type="customvar_copy"><i class="layui-icon layui-icon-fonts-code"></i>复制标签</a></div>
            </div>
            
            <div class="pcfline"></div>
            <div class="layui-form-item" style="padding-top:20px;">
              <label class="layui-form-label pcfcms_layui-form-label" style="padding:5px 15px;"><strong>自定义变量</strong></label>
              <div class="layui-input-inline layadmin-layer-demo">
                <button class="layui-btn layui-btn-sm" data-type="customvar_index">管理</button>
              </div>
            </div>
            {volist name="pcf_row" id="vo"}
            <div class="layui-form-item" id="dl_{$vo['attr_var_name']}">
              <label class="layui-form-label pcfcms_layui-form-label">{$vo['attr_name']}</label>
              {switch name="$vo['attr_input_type']" }
                {case value="1"}
                {/case}
                {case value="2"}
                <div class="layui-input-inline pcfcms_layui-input-inline">
                  <textarea name="{$vo['attr_var_name']}" id="{$vo['attr_var_name']}" class="layui-textarea">{$vo.value|default=''}</textarea>
                </div>
                {/case}
                {case value="3"}
                <div class="layui-input-inline auto">
                <ul class="layout">
                  <li>
                  <input type="text" class="layui-input inp inp_logo" name="{$vo['attr_var_name']}" id="{$vo['attr_var_name']}" placeholder="图片地址" value="{$vo.value|default=''}">
                  <img id="img_{$vo['attr_var_name']}" src="{$vo.value|get_default_pic=###}" class="none">
                  </li>
                  <li style="margin-top:3px;margin-left:5px;">
                  <div class="layui-btn-group">
                    <input type="button" value="上传图片" class="layui-btn layui-btn-sm pcfcms-upload" lay-data="{number:1,pcf_inputId:'{$vo['attr_var_name']}',pcf_savepath:'allimg'}">
                    <input type="button" value="选择图片" class="layui-btn layui-btn-sm" onClick="GetPictureFolder(1,'{$vo['attr_var_name']}');">
                    <input type="button" value="预览" class="layui-btn layui-btn-sm" onclick="BigImages($('#img_{$vo['attr_var_name']}').attr('src'));">
                    <input type="button" value="清除" class="layui-btn layui-btn-sm layui-btn-warm" data-inputid="{$vo['attr_var_name']}" onclick="DelImages(this);">
                  </div>
                  </li>
                </ul>
                </div>
                {/case}
                {default/}
                <div class="layui-input-inline pcfcms_layui-input-inline">
                  <input type="text" id="{$vo['attr_var_name']}" name="{$vo['attr_var_name']}" value="{$vo.value|default=''}" lay-verify="title" class="layui-input">
                </div>
              {/switch}
            </div>
            {/volist}
        </div>
        </div>
      </div>
    </div>
    <div class="pcfclear"></div>
  </div>
  <div class="submit-info text-center">
      <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
  </div>
</div>
{include file="public/loading"/}
{include file="public/footer"/}
<script type="text/javascript">
    layui.use(['layer', 'form','element'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;

        $('#LAY-component-layer-list .layui-btn').on('click', function(){
          var type = $(this).data('type');
          active[type] && active[type].call(this);
        });

        //触发事件
        var active = {
          customvar_index: function(){
            layer.open({
                type: 2,
                title: '自定义变量列表',
                fixed: true,
                shadeClose: false,
                shade: 0.3,
                area: ['100%', '100%'],
                content: "{:url('/web/customvar_index')}",
                end: function(){
                  window.location.reload();
                }
            });
          },
          customvar_copy: function(){
            var classname = $(this).data('attr');
            var clipboard1 = new Clipboard("."+classname);
            clipboard1.on("success", function(e) {layer.msg("复制成功", {time: 1000});});
            clipboard1.on("error", function(e) {layer.msg("复制失败！请手动复制", {icon:2});}); 
          }
        };

        // 监听开关
        form.on('switch', function(data){
          var elemId = data.elem.attributes['lay-filter']['nodeValue'];
          if (data.elem.checked) {
            this.value = 1;
          } else {
            this.value = 0;
          }
          $("input[name='"+elemId+"']").val(this.value);
        });

        //监听提交
        form.on('submit(formSubmit)', function(data){
            layer.msg('正在处理请勿刷新页面', {icon: 16,shade: 0.01,time:3600000});
            $.ajax({
                type : 'post',
                url : "{:url('/web/index')}",
                data : data.field,
                dataType : 'json',
                success : function(res){
                    layer.closeAll('loading');
                    if(res.status){
                        layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                            window.location.reload();
                        });
                    }else{
                      layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                },
                error: function(e){
                    layer.closeAll('loading');
                    layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                }
            });
            return false;
        });

  });
</script>
</body>
</html>